﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace Business_Layer
{
    [Serializable]
    public abstract class Component
    {
        protected int sx, sy;
        protected int ex, ey;
        protected string text;

        protected IColorBehaviour colorBehaviour;

        public Component(int sx,
                         int sy,
                         int ex,
                         int ey,
                         string text)
        {
            this.sx = sx;
            this.sy = sy;
            this.ex = ex;
            this.ey = ey;
            this.text = text;
        }

        public abstract void ChangeColor(Color color);
        public abstract Graphics Draw(Graphics g);

        protected string alternateString = null;
        public virtual string AlternateString
        {
            get { return alternateString; }
            set { alternateString = value; }
        }

        /// <summary>
        /// Change the components text.
        /// </summary>
        /// <param name="text"></param>
        public void ChangeText(string text)
        {
            this.text = text;
        }

        /// <summary>
        /// Move the component in a specified direction.
        /// </summary>
        /// <param name="dx">Direction X.</param>
        /// <param name="dy">Direction Y</param>
        public virtual void Move(int dx, int dy)
        {
            sx = sx + dx;
            ex = ex + dx;
            sy = sy + dy;
            ey = ey + dy;
        }

        /// <summary>
        /// Get the components bounds.
        /// </summary>
        public Rectangle GetBounds
        {
            get { return new Rectangle(sx, sy, ex, ey); }
        }

        /// <summary>
        /// Get the components text.
        /// </summary>
        /// <returns></returns>
        public string GetText()
        {
            return text;
        }

        /// <summary>
        /// Returns the components position.
        /// </summary>
        public Point Position
        {
            get { return new Point((sx + ex) / 2, (sy + ey) / 2); }
        }
    }
}
